package com.lm.shop.order.controller;

import com.lm.shop.common.utils.R;
import com.lm.shop.order.feign.ProductFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lsk
 * @version 1.0.0
 * @ClassName OrderController.java
 * @Description 订单控制层
 * @createTime 2022年10月19日 19:17:00
 */
@RestController
@RequestMapping("sku")
public class SkuController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    ProductFeignService productFeignService;

     private static final String PRODUCT_SERVER  = "http://SHOP-PRODUCT/";

    @GetMapping("/getProduct")
    public R getProduct(){
        ResponseEntity<R> responseEntity = restTemplate.getForEntity(PRODUCT_SERVER + "/product/getProductById?id=1",R.class);
        return R.ok().setData(responseEntity.getBody());
    }

    @GetMapping("/getOrder")
    public R getOrder(){
        return this.productFeignService.getProductById(2L);
    }
}
